/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package cn.ekuma.data.ui.swing;

import e.odbo.data.dao.I_ParentNode;
import e.odbo.data.bean.IKeyed;

import com.openbravo.data.user.DirtyManager;
import java.util.ArrayList;
import java.util.List;
import java.util.Properties;

/**
 *
 * @author Administrator
 */
public abstract class AbstractParentDAOJEditor<T extends IKeyed,K> extends AbstractDAOJEditor<T> implements I_ParentNode<K>{

    protected List<ParentNodeChangeListener<K>> listeners = new ArrayList();

    public AbstractParentDAOJEditor(DirtyManager dirty) {
        super(dirty);
    }

     public final void addObjectChangeListener(ParentNodeChangeListener<K> l) {
        listeners.add(l);
    }

    public final void removeListDataListener(ParentNodeChangeListener<K> l) {
        listeners.remove(l);
    }

    @Override
    public void writeValueInsert(Properties prop) {
        super.writeValueInsert(prop);
        for(ParentNodeChangeListener l:listeners)
            l.parentNodeValueChange(state, this);
    }

    public void writeValueDelete(T value) {
       super.writeValueDelete(value);
       for(ParentNodeChangeListener l:listeners)
            l.parentNodeValueChange(state, this);
    }

    public void writeValueEOF() {
       super.writeValueEOF();
       for(ParentNodeChangeListener l:listeners)
            l.parentNodeValueChange(state, this);
    }

    public void writeValueEdit(T value) {
       super.writeValueEdit(value);
       for(ParentNodeChangeListener l:listeners)
            l.parentNodeValueChange(state, this);
    }


    public IKeyed<K> getParentKey() {
        return obj;
    }

    public Class getParentClass() {
        return getEditClass();
    }



}
